<?php

$pluginName = 'name';
class metadataPlugins_name extends BaseMetadata
{
	public function saveMeta()
	{
		$type = $this->file->getType();
		$level1 = $level2 = $level3 = array();
		$level1 = $this->getDirectories($this->file->getName());
		if(isForeachable($level1)) foreach($level1 as $l1)
		{
			$level2 = $this->maxMeta($l1);
			if(isForeachable($level2)) foreach($level2 as $l2)
			{
				$level3 = array_merge($level3, $this->unCamelize($l2));
			}
		}
		
		
		foreach($level3 as $r)
		{
			$r = trim(strtolower($r));
			if(!empty($r))
			{
				$this->addMetadata($r, $type);
			}
		}
		
		return parent::saveMeta();
	}
	
	public function maxMeta($str)
	{
		if(!INCLUDE_EXTENSION_IN_METADATA)
		{
			$t = explode('.', $str);
			array_pop($t);
			$str = implode('.',$t);
		}
		return split('[^A-Za-z]', $str);
	}
	
	public function getDirectories($str)
	{
		return explode(OS_PATH_SEPARATOR, $str);
	}
	
	public function unCamelize($str)
	{
		return JGLib::unCamelize($str);
	}
	
	public static function getPluginName()
	{
		return 'name';
	}
	
	public static function getPluginDescription()
	{
		return 'metadata based on the filename';
	}
	
	public static function getExtensionHandle()
	{
		return true; // true is a special value to allow handling for all extentions
		return array('jpg');
	}
}
